import {
  q as i,
  p as W,
  ap as z,
  X as p,
  f as D,
  H as M,
  av as f,
  aw as U,
  k as g,
  m as h,
  l as m,
  as as s,
  at as d
} from "./index-b50e6ef9.js";
import { g as A, a as y } from "./goods-bd9f9b53.js";
function H(v) {
  const l = i([]),
    t = i(!0);
  i({}), W(), i(!1);
  const w = z("reload"),
    x = p({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    b = p({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "type_id", minWidth: 50 },
      { label: "分类名称", prop: "type_name", minWidth: 200 },
      {
        label: "状态",
        prop: "type_status",
        minWidth: 100,
        formatter: ({ type_status: e }) => {
          if (e == 1)
            return g(
              m("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [h("启用")] }
            );
          if (e == 2)
            return g(
              m("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [h("禁用")] }
            );
        }
      },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    S = D(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function C(e) {
    const n = { type_id: e.type_id },
      c = JSON.stringify(n),
      a = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(c)) },
      o = await A(a);
    o.code == 200
      ? (d("删除成功", { type: "success" }), w())
      : d(o.msg, { type: "error" });
  }
  function I() {}
  function J(e) {}
  function k(e) {}
  function T(e) {}
  function _(e) {
    (b.text = `正在加载第${e}页...`),
      (t.value = !0),
      f(600).then(() => {
        t.value = !1;
      });
  }
  async function u(e, n) {
    t.value = !0;
    const r = JSON.stringify({ wares_id: e, wares_status: n }),
      o = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(r)) },
      { data: V } = await y(o);
    (l.value = V),
      setTimeout(() => {
        t.value = !1;
      }, 500);
  }
  async function L() {
    const n = JSON.stringify({ page: 1, pagesize: 20, str: "warse" }),
      r = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(n)) },
      a = await y(r);
    a.code === 200
      ? ((l.value = a.data),
        setTimeout(() => {
          t.value = !1;
        }, 500))
      : d(a.msg, { type: "error" });
  }
  const N = e => {
    e && (e.resetFields(), u());
  };
  return (
    M(() => {
      f().then(() => {
        const { setWatermark: e } = U(v.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        L();
    }),
    {
      loading: t,
      columns: B,
      dataList: l,
      pagination: x,
      buttonClass: S,
      onSearch: u,
      resetForm: N,
      handleaddUser: I,
      handleDelete: C,
      handleSizeChange: J,
      handleCurrentChange: k,
      handleSelectionChange: T,
      onCurrentChange: _
    }
  );
}
export { H as useRole };
